from base.group import BaseGroup
from settings import *


class NoneGroup(PG.sprite.Group):
    pass


class DisplayGroup(BaseGroup):
    pass


class PlayerGroup(BaseGroup):
    pass


class EnemyGroup(BaseGroup):
    pass


class DamageGroup(BaseGroup):
    pass


class CollisionGroup(BaseGroup):
    pass


class PlayerAttackGroup(BaseGroup):
    pass


class EnemyAttackGroup(BaseGroup):
    pass


class UpdateGroup(BaseGroup):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.display_surface = PG.display.get_surface()
        self.sps_mapping = {k.value: list() for k in PGLayers}

    def custom_draw(self):
        for sprite in sorted(self.sprites(), key=lambda sp: sp.rect.centery):
            self.sps_mapping[sprite.z].append(sprite)
        for sprites in self.sps_mapping.values():
            for sprite in sprites:
                self.display_surface.blit(sprite.image, sprite.rect, sprite.area)
        self.sps_mapping = {k.value: list() for k in PGLayers}
